<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
<!-- bootstrap table js -->
<script src="../bootstrapTable/dist/bootstrap-table.js"></script>
<script src="../bootstrapTable/dist/locale/bootstrap-table-zh-CN.js"></script>
	
<script src="ship.js"></script>
	<script type="text/javascript">
	$(function(){
		//绑定机构下拉列表（出发港）
		bindDeparturePortOrg();

		//绑定机构下拉列表（目的港）
		bindDestinationPortOrg();
		
	    $('#departureportcode').select2({  
	        placeholder: "请选择出发港",  
	        width:'100%'  
	    });  
	    $('#departureportcode').change(function(){
	    	var text= $(this).select2('data')[0].text;
	    	$('#departureportname').val(text);
	    })
	    
	    $('#destinationportcode').select2({  
	        placeholder: "请选择目的港",  
	        width:'100%'  
	    });  
	    $('#destinationportcode').change(function(){
	    	var text= $(this).select2('data')[0].text;
	    	$('#destinationportname').val(text);
	    })
	})
	
	
	
	function bindDeparturePortOrg(){
		$.ajax({ 
			method: 'post',
			url: projectPath + "share/getOrg.do",
			dataType: "json",
			contentType: "application/json",
			success: function(data){
			    var cityPicker = new IIInsomniaCityPicker({
			        data: data,
			        target: '#departureportorg',
			        callback: function(id){
						if(id != 0){
							$('#departureportorgcode').val(id);
							$('#departureportorgname').val($('#departureportorg').val());

					 		var param = {};
					 		param['orgcode'] = id;

					 		bindPort('departureportcode', param, null);
						}
			        }
			    });
	
			    cityPicker.init();
			    
			    if($('#departureportorgcode').val() != ''){
				    $('#departureportorg').val($('#departureportorgname').val());
				    $('#departureportorg').attr('data', $('#departureportorgcode').val());
				    
// 			 		var param = {};
// 			 		param['orgcode'] = $('#departureportorgcode').val();
// 			 		bindPort('departureportcode', param, null);
			    }
			}
		});
	}

	function bindDestinationPortOrg(){
		$.ajax({ 
			method: 'post',
			url: projectPath + "share/getOrg.do",
			dataType: "json",
			contentType: "application/json",
			success: function(data){
			    var cityPicker = new IIInsomniaCityPicker({
			        data: data,
			        target: '#destinationportorg',
			        callback: function(id){
						$('#destinationportorgcode').val(id);
						$('#destinationportorgname').val($('#destinationportorg').val());

				 		var param = {};
				 		param['orgcode'] = id;

				 		bindPort('destinationportcode', param, null);
			        }
			    });
	
			    cityPicker.init();

			    if($('#destinationportorgcode').val() != ''){
				    $('#destinationportorg').val($('#destinationportorgname').val());
				    $('#destinationportorg').attr('data', $('#destinationportorgcode').val());
			    }
			}
		});
	}
	</script>
</head>
<body>
		<div class="panel panel-primary">
			<div class="panel-heading">
				<h3 class="panel-title">申请单信息</h3>
			</div>

			<div class="panel-body">
				<form id="Business">
					<table class="table table-bordered">
					<tbody>
						<tr>
							<td style="width:130px; text-align: right; background-color: #eee; ">
								报送机构：<span style="color:red;">*</span>
							</td>
							<td colspan="5">
    							<input style="width: 200px;" type="text" class="form-control" id="org" placeholder="请选择报送机构">
							</td>
						</tr>
						<tr>
							<td style="width:130px; text-align: right; background-color: #eee; ">
								船舶：<span style="color:red;">*</span>
							</td>
							<td colspan="5">
								<div class="input-group" style="width:30%;">
									<input type="text" class="form-control" disabled="disabled" id="ship" placeholder="选择作业船舶">
									<span class="input-group-btn">
										<button class="btn btn-primary" type="button" id="selectShip">
											选择船舶
										</button>
									</span>
								</div>
							</td>
						</tr>
						<tr>
							<td style="width:130px; text-align: right; background-color: #eee; ">
								出发港：<span style="color:red;">*</span>
							</td>
							<td colspan="5">
								<div class="row">
									<div class="col-lg-3">
										<input type="text" class="form-control" id="departureportorg" placeholder="请选择出发港机构">
										<input type="hidden" id="departureportorgcode" name="departureportorgcode">
										<input type="hidden" id="departureportorgname" name="departureportorgname">
									</div>
									<div class="col-lg-3">
										<select class="combox" placeholder="请选择出发港" id="departureportcode" name="departureportcode"></select>
										<input type="hidden" id="departureportname" name="departureportname">
									</div>
								</div> 
							</td>
						</tr>
						<tr>
							<td style="width:130px; text-align: right; background-color: #eee; ">
								目的港：<span style="color:red;">*</span>
							</td>
							<td colspan="3">
								<div class="row">
									<div class="col-lg-5" style="width: 40.2%;">
										<input type="text" class="form-control" id="destinationportorg" placeholder="请选择目的港机构">
										<input type="hidden" id="destinationportorgcode" name="destinationportorgcode">
										<input type="hidden" id="destinationportorgname" name="destinationportorgname">
									</div>
									<div class="col-lg-5" style="width: 40.2%;">
										<select class="combox" placeholder="请选择目的港" id="destinationportcode" name="destinationportcode"></select>
										<input type="hidden" id="destinationportname" name="destinationportname">
									</div>
								</div> 
							</td>
							<td style="width:130px; text-align: right; background-color: #eee; ">
								抵达本港时间：
							</td>
							<td>
								<input type="date" class="form-control" id="destinationporttime" name="destinationporttime" placeholder="请选择抵达本港时间">
							</td>
						</tr>
						<tr>
							<td style="width:130px; text-align: right; background-color: #eee; ">
								客货情况：<span style="color:red;">*</span>
							</td>
							<td colspan="5">
								<textarea rows="2" class="form-control" name="freightsituation" placeholder="请输入客货情况"></textarea>
							</td>
						</tr>
						<tr>
							<td style="width:130px; text-align: right; background-color: #eee; ">
								事件时间：<span style="color:red;">*</span>
							</td>
							<td>
								<input type="date" class="form-control" name="eventtime" placeholder="请选择日期">
							</td>
							<td style="width:130px; text-align: right; background-color: #eee; ">
								事件地点：<span style="color:red;">*</span>
							</td>
							<td>
								<input type="text" class="form-control" name="eventplace" placeholder="请输入地点">
							</td>
							<td style="width:130px; text-align: right; background-color: #eee; ">
								当时气象情况：
							</td>
							<td>
								<input type="text" class="form-control" name="weather" placeholder="请输入当时气象情况">
							</td>
						</tr>
						<tr>
							<td style="width:130px; text-align: right; background-color: #eee; ">
								当时海况：
							</td>
							<td colspan="5">
								<textarea rows="2" class="form-control" name="seacondition" placeholder="请输入当时海况"></textarea>
							</td>
						</tr>
						<tr>
							<td style="width:130px; text-align: right; background-color: #eee; ">
								事件过程：
							</td>
							<td colspan="5">
								<textarea rows="4" class="form-control" name="eventprocess" placeholder="请输入事件过程"></textarea>
							</td>
						</tr>
						<tr>
							<td style="width:130px; text-align: right; background-color: #eee; ">
								措施：
							</td>
							<td colspan="5">
								<textarea rows="4" class="form-control" name="emergentstep" placeholder="请输入措施"></textarea>
							</td>
						</tr>
					</tbody>
					</table>
					
	            </form>
			</div>
		</div>
</body>
</html>